/**
 * Created with IntelliJ IDEA.
 * Description:求最后一个单词的长度
 * User: 86187
 * Date: 2022-05-23
 * Time: 17:32
 */

public class LengthOfLastWord {

    public static int lengthOfLastWord(String s) {
        s = s.trim();
        return s.length() - s.lastIndexOf(" ") - 1;
    }

    public static void main(String[] args) {
        String s = "hello world ";
        System.out.println(lengthOfLastWord(s));
    }
}
